package by.epam.xslttask.managers;

import by.epam.xslttask.logger.LoggerType;
import by.epam.xslttask.logger.XSLTLogger;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * Created by IntelliJ IDEA.
 * User: Darya_Hrishanovich
 * Date: 7/6/12
 * Time: 4:43 AM
 * To change this template use File | Settings | File Templates.
 */
public class LogManager {
    private static ResourceBundle resourceBundle;

    public static final String LOG_PATH = "properties.log";
    public static final String RES_MISSING = "resMissing";
    public static final String SAX_EXCEPTION = "saxException";
    public static final String PARSER_CONFIG_ERROR = "parserConfigException";
    public static final String TRANS_CONFIG_ERROR = "transformConfigException";
    public static final String TRANS_FACTORY_ERROR = "transformFactoryError";
    public static final String TRANSFORM_ERROR = "transformError";
    public static final String FILE_NOT_FOUND = "fileNotFound";
    public static final String IO_EXCEPTION = "ioException";
    public static final String EMPTY_MODEL = "emptyModel";
    public static final String EMPTY_PRODUCER = "emptyProducer";
    public static final String EMPTY_NAME = "emptyName";
    public static final String EMPTY_DATE = "emptyDate";
    public static final String EMPTY_COLOR = "emptyColor";
    public static final String EMPTY_PRICE = "emptyPrice";
    public static final String INVALID_MODEL = "invalidModel";
    public static final String INVALID_DATE = "invalidDate";
    public static final String INVALID_COLOR = "invalidColor";
    public static final String INVALID_PRICE = "invalidPrice";

    static {
        resourceBundle = ResourceBundle.getBundle(LOG_PATH);
    }

    public static String getProperty(String key) {
        try {
            return resourceBundle.getString(key);
        } catch (MissingResourceException ex) {
            String message = LogManager.getProperty(LogManager.RES_MISSING);
            XSLTLogger.logMessage(message, LogManager.class, LoggerType.WARNING);
        }
        return "";
    }
}
